package org.dev.vlp.controller;

import org.dev.vlp.bean.JsonResponse;
import org.dev.vlp.constants.EnumLikeTargetType;
import org.dev.vlp.constants.Roles;
import org.dev.vlp.dto.PublishMomentParam;
import org.dev.vlp.interceptor.RequiredPermission;
import org.dev.vlp.service.LikeService;
import org.dev.vlp.service.MomentService;
import org.dev.vlp.vo.MomentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * Description
 * Param
 * return
 * Author:86184
 * Date: 2023/1/14
 */
@RestController
@RequestMapping("/like")
@RequiredPermission({Roles.ROLE_USER})
public class LikeController extends BaseController{
    @Autowired
    private LikeService likeService;


    @PostMapping(value = "/{targetId}")
    public JsonResponse<Object> like(@PathVariable("targetId") int targetId,
                                                @RequestParam EnumLikeTargetType type) {
        likeService.like(type, (long) targetId,getUid());
        return JsonResponse.success();
    }

    @DeleteMapping(value = "/{targetId}")
    public JsonResponse<Object> deleteLike(@PathVariable("targetId") int targetId,
                                              @RequestParam EnumLikeTargetType type) {

        likeService.cancelLike(type, (long) targetId,getUid());
        return JsonResponse.success();
    }
}
